package com.hzit.portal.excep;

import cn.hutool.core.util.StrUtil;
import com.alibaba.csp.sentinel.slots.block.flow.FlowException;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * 类名：
 * 作者：WF
 * 功能：全局异常处理
 */
// @ControllerAdvice
public class HandlerBlockException {

	@ExceptionHandler(FlowException.class)
	public String errorView(Model model,FlowException e){
		String msg = "限流异常！";
		if(e != null && StrUtil.isNotBlank(e.getMessage())){
			msg = e.getMessage();
		}
		model.addAttribute("msg",msg);
		return "error";
	}
}
